package com.fq.modules.sys.role.controller;

import com.fq.api.api.ApiRest;
import com.fq.api.api.controller.BaseController;
import com.fq.modules.sys.role.dto.SaveRolesDTO;
import com.fq.modules.sys.role.entity.SysRole;
import com.fq.modules.sys.role.service.SysUserRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author 超chao
 * @Description 系统用户角色控制器
 * @Date 2024/10/21/周一 8:57
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/sys/user-role")
@Api(tags = "系统用户角色")
public class UserRoleController extends BaseController {

    @Autowired
    private SysUserRoleService baseService;
    @ApiOperation(value = "查询--查询用户权限")
    @RequestMapping(value = "/findUserPermission",method = {RequestMethod.GET})
    public ApiRest<List<String>> findUserPermission(@RequestParam(value = "userId") Long userId){
        return super.success(baseService.findUserPermission(userId));

    }
    @ApiOperation(value = "查询--用户角色")
    @RequestMapping(value = "/userRole",method = {RequestMethod.GET})
    public ApiRest<SysRole> userRole(@RequestParam(value = "userId") Long userId){
        return super.success(baseService.userRole(userId));
    }

    @ApiOperation(value = "操作--保存用户角色")
    @RequestMapping(value = "/saveUserRole",method = {RequestMethod.POST})
    public ApiRest<SaveRolesDTO> saveRoles(@RequestBody SaveRolesDTO dto){
        baseService.saveUserRole(dto);
        return super.success(dto);
    }

}
